package com.program.facesigninsystem.dao;

import com.program.facesigninsystem.entity.SignInRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ISignInRecordDao {
    /****
     * 返回某签到环节的签到结果(教师端)
     * @Param lid
     * @return
     */
    List<Map<String, Object>> selectRecordList(@Param("lid")String lid);

    /****
     * 返回某签到环节的签到人数(教师端)
     * @Param lid
     * @return
     */
    int selectRecCount(@Param("lid")String lid);

    /****
     * 返回某签到环节未签到成员(教师端)
     * @Param cid
     * @Param lid
     * @return
     */
    List<Map<String,Object>> selectNoSignIn(@Param("cid")String cid,@Param("lid")String lid);

    /***
     * 学生扫描二维码新增签到记录
     * @param lid
     * @param uid
     */
    void addNewRecord(@Param("id")String id,@Param("lid")String lid,@Param("uid")String uid,@Param("createTime")String createTime);

    void addNewRecordWithState(@Param("id")String id,@Param("lid")String lid,@Param("uid")String uid,@Param("createTime")String createTime,@Param("state")String state);

    /***
     * 按日期查询签到记录
     * @param uid
     * @param date1
     * @param date2
     * @return
     */
    List<SignInRecord> selectRecord(@Param("uid")String uid,@Param("date1")String date1,@Param("date2")String date2);

    List<SignInRecord> selectRecordByMonth(
            @Param("uid")String uid,
            @Param("createTime")String createTime
    );

    /***
     * 查询全部签到记录
     * @param uid
     * @return
     */
    List<SignInRecord> selectRecordAll(@Param("uid")String uid);

    /****
     * 查找签到记录是否存在
     * @param uid
     * @param lid
     * @return
     */
    SignInRecord selectRecExist(@Param("uid")String uid,@Param("lid")String lid);

    /****
     * 查询总排名
     * @return
     */
    List<Map<String,Object>>selectRank();

    /****
     * 按日期查询待签到
     * @param uid
     * @param date
     * @return
     */
    List<Map<String,Object>>selectMyRecord(@Param("uid")String uid,@Param("date")String date);

    /****
     * 查询签到结果(分页、有序)
     * @param lid
     * @return
     */
    List<Map<String,Object>> selectList(@Param("lid")String lid);

    /***
     * 老师代签
     * @param id
     * @param uid
     * @param lid
     * @param createTime
     * @param state
     */
    void signInByTea(@Param("id")String id,@Param("uid")String uid,@Param("lid")String lid,@Param("createTime") String createTime,@Param("state")String state);

    /***
     * 已签到结果
     * @param lid
     */
    List<Map<String,Object>> findSignIn(@Param("lid")String lid);

    /***
     * 未签到结果
     * @param cid
     * @param lid
     */
    List<Map<String,Object>> findNoSignIn(@Param("cid")String cid,@Param("lid")String lid);

    List<Map<String,Integer>> selectDistinctState(@Param("lid")String lid);

    void setSignInState(@Param("uid")String uid,@Param("lid")String lid,@Param("state")String state);
}
